package com.woniuxy.microsyslogserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.bean.SystemLogBean;
import com.woniuxy.microsyslogserver.dao.SysLogDao;
import com.woniuxy.microsyslogserver.service.SysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description: 系统操作日志业务服务层实现类
 *
 * @Auther: HanLei
 * @Date: 2021/4/9:16:10
 */
@Slf4j
@Service
public class SysLogServiceImpl implements SysLogService {

    @Resource
    private SysLogDao sysLogDao;

    @Override
    public PageInfo<SystemLogBean> queryAll(SystemLogBean systemLogBean, int pageNum, int pageSize) {
        try {
            PageHelper.startPage(pageNum, pageSize);
            List<SystemLogBean> systemLogBeans = sysLogDao.queryAll(systemLogBean);
            return new PageInfo<SystemLogBean>(systemLogBeans);
        } catch (Exception e) {
            log.error("查询异常：", e.fillInStackTrace());
            return null;
        }
    }

    @Override
    public int insert(SystemLogBean systemLogBean) {
        try{

            return sysLogDao.insert(systemLogBean);
        } catch (Exception e) {
            log.error("日志插入异常：", e.fillInStackTrace());
            return 0;
        }
    }
}
